<?php
/**
 * Created by PhpStorm.
 * User: zhd
 * Date: 2019/6/11
 * Time: 21:31
 */

namespace app\Module\Index\Controller;


use FFMpeg\Coordinate\TimeCode;
use FFMpeg\FFMpeg;

class DebugController
{
    private $videoPath = APP_PATH . '/upload/video/';

    public function redisAction()
    {
        $key = redis_db()->keys('*');
        var_dump($key);
    }

    public function ffmpegAction()
    {
        $ffmpeg   = FFMpeg::create([
            'ffmpeg.binaries'  => '/usr/bin/ffmpeg',
            'ffprobe.binaries' => '/usr/bin/ffprobe',
            'timeout'          => 3600, // The timeout for the underlying process
            'ffmpeg.threads'   => 12,   // The number of threads that FFMpeg should use
        ]);
        $videoObj = $ffmpeg->open($this->videoPath . '/5ca4c43673b76_1858.mp4');
        $imageUrl = $this->videoPath . '5ca4c43673b76_1858';
        $videoObj->frame(TimeCode::fromSeconds(1))->save($imageUrl . '.jpg');
        var_dump($imageUrl);
    }
}